{extend name="public:layout" /}
{block name="title"}添加优惠券{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> <a href="{:url('index')}"> 优惠券列表</a></li>
                <li class="active">添加优惠券</li>
            </ol>
        </div>
        <div class="ibox-content">
            <form method="post" class="form-horizontal" id="form">
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">优惠券标题</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" datatype="*" name="title" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">副标题</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" datatype="*" name="sub_title" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">代金券图片</label>
                    <div class="col-sm-8">
                        {:widget('common/Form/singleImg',['field'=>'card_image','',$uid])}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">发放类型</label>
                    <div class="col-sm-4">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="send_type" value="0" checked/> 线上发放
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="send_type" value="1"/> 线下发放
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="send_type" value="2"/> 在线购买
                        </label>
                    </div>
                    <label class="col-sm-2 control-label Validform_label">有效期类型</label>
                    <div class="col-sm-4">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="date_type" value="DATE_TYPE_FIX_TIME_RANGE" checked/> 固定日期区间
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="date_type" value="DATE_TYPE_FIX_TERM"/> 固定时长
                        </label>
                    </div>
                </div>
                <div class="DATE_TYPE_FIX_TIME_RANGE date-type">
                    <div class="form-group">
                        <label class="col-sm-2 control-label Validform_label">开始日期</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control laydate" name="begin_timestamp" value="" />
                            <p class="help-block">该优惠卷生效日期，当前0:00:00生效</p>
                        </div>
                        <label class="col-sm-2 control-label Validform_label">结束日期</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control laydate" name="end_timestamp" value="" />
                            <p class="help-block">该优惠卷失效日期，当天23:59:59秒截止</p>
                        </div>
                    </div>
                </div>
                <div class="DATE_TYPE_FIX_TERM date-type" style="display:none;">
                    <div class="form-group">
                        <label class="col-sm-2 control-label Validform_label">多少天后生效</label>
                        <div class="col-sm-4">
                            <input class="form-control" name="fixed_begin_term" value="" type="text" />
                            <p class="help-block">表示自领取后多少天后开始生效，领取后当天生效填写0</p>
                        </div>
                        <label class="col-sm-2 control-label Validform_label">有效天数</label>
                        <div class="col-sm-4">
                            <input class="form-control" name="fixed_term" value="" type="text" />
                            <p class="help-block">表示自生效后多少天内有效，不支持填写0</p>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">代金券面额</label>

                    <div class="col-sm-4">
                        <input class="form-control" name="card_money" value="" datatype="*" type="text"/>
                        <p class="help-block">代金券金额</p>
                    </div>
                    <label class="col-sm-2 control-label Validform_label">订单金额</label>

                    <div class="col-sm-4">
                        <input class="form-control" name="card_order_money" value="0" type="text"/>
                        <p class="help-block">满足该订单金额才可使用,不限制请填0</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">购买金额</label>

                    <div class="col-sm-4">
                        <input class="form-control" name="sale_money" value="0" type="text"/>
                        <p class="help-block">勾选在线购买该金额生效</p>
                    </div>
                    <label class="col-sm-2 control-label Validform_label">库存</label>

                    <div class="col-sm-4">
                        <input class="form-control" name="quantity" value="0" type="text" datatype="n"/>
                        <p class="help-block">库存0表示不限制发放数量</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label Validform_label">使用说明</label>
                    <div class="col-sm-10">
                        <textarea class="form-control" rows="5" name="direction"></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-2">
                        <button class="btn btn-primary" type="button" id="btnSub">确 认</button>
                        <a href="{:url('index')}" class="btn btn-white">取消</a>
                        <span id="validError"></span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        iCheck();
        formatDate();
        ajaxSubForm('#btnSub');
        $("input[name='date_type']").on('ifChecked', function(event){
            var dateType = $('input[name="date_type"]:checked ').val();
            $('.date-type').hide();
            $('.'+dateType).show();
        });
    })
</script>
{/block}